package com.cs.pk.actions;

import java.net.URL;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;

import com.cs.pk.utils.Constants;

public class ShowCodeStriker implements IWorkbenchWindowActionDelegate {

	private IWorkbenchWindow parent = null;
	public void dispose() {
         parent = null;
	}

	public void init(IWorkbenchWindow window) {
         parent = window;
	}

	public void run(IAction action) {
          try {
        	  IWebBrowser browser =  parent.getWorkbench().getBrowserSupport().createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR,
        			  "CodeStriker", "CodeStriker","Code Striker website");
        	  browser.openURL(new URL(PlatformUI.getPreferenceStore().getString(Constants.CODESTRIKERURL)!=null?
        			  PlatformUI.getPreferenceStore().getString(Constants.CODESTRIKERURL):PlatformUI.getPreferenceStore().getDefaultString(Constants.CODESTRIKERURL)));
          }catch(Exception e) {
        	  e.printStackTrace();
          }
	}

	public void selectionChanged(IAction action, ISelection selection) {

	}

}
